package com.itheima.controller;

import com.itheima.common.CommonResult;
import com.itheima.common.PageInfo;
import com.itheima.pojo.Order;
import com.itheima.service.OrderService;
import com.itheima.service.SetmealService;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * @author YangJiaHao
 */
@RestController
@RequestMapping("order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @GetMapping("/page")
    public CommonResult page(LocalDateTime beginTime,
                             LocalDateTime endTime,
                             String number,
                             @RequestParam(defaultValue = "1") Integer page,
                             @RequestParam(defaultValue = "10")Integer pageSize){
        PageInfo<Order> pageInfo = orderService.page(beginTime,endTime,number,page,pageSize);
        return CommonResult.success(pageInfo);
    }

    @PutMapping
    public CommonResult updateStatus(@RequestBody Integer status,@RequestBody String id){
        orderService.updateStatus(status,id);
        return CommonResult.success("操作成功");
    }
}
